<?php

namespace app\data\controller\shop;

use app\data\service\GoodsService;
use think\admin\Controller;

/**
 * 投资报表
 * Class Portal
 * @package app\data\controller\total
 */
class Report extends Controller
{
    /**
     * 金融数据报表
     * @auth true
     * @menu true
     */
    public function index()
    {

        $id = input('goods_id');
        $where = [];

        $where[] = ['deleted_status', '=', 0];
        $where[] = ['status', '<>', 0];

        if ($id){
            $where[] = ['goods_id', '=', $id];
        }

        $this->goodsLxjeTotal   = $this->app->db->name('ShopOrder')->where($where)->sum('expect_lxje');
        $this->goodsOrderTotal  = $this->app->db->name('ShopOrder')->where($where)->count();
        $this->goodsAmountTotal = $this->app->db->name('ShopOrder')->where($where)->sum('money');

        if ($this->request->isGet()){
            $this->companys = GoodsService::instance()->getCompanyData();
            $this->cates    = input('company_id') ? GoodsService::instance()->getCateDataByCompanyId(input('company_id')) : 0;
            $this->goodsList    = input('cate_id') ? GoodsService::instance()->getGoods(['cate_id' => input('cate_id')]) : 0;
        }

        $this->fetch();
    }

    public function _index_page_filter(&$data){



    }

}